package cn.itcast.activiti.servlet.user;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.TaskService;

import cn.itcast.activiti.common.ProcessEngineUtils;

/**
 * 完成任务
 * @author Administrator
 *
 */
@WebServlet("/completeTask.action")
public class CompleteTaskServlet extends HttpServlet{


	private static final long serialVersionUID = 6519741381423481496L;
	
	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		//获取任务ID
		String taskId=request.getParameter("taskId");
		
		//获取流程引擎
		ProcessEngine processEngine=ProcessEngineUtils.getProcessEngine();
		//获取任务服务
		TaskService taskService=processEngine.getTaskService();
		//完成任务
		taskService.complete(taskId);
		
		response.sendRedirect(request.getContextPath()+"/queryUserTask.action");
		
		
		
	}
	
	

}
